import Vue from 'vue'
import VueRouter from 'vue-router'

import Index from '../views/Index.vue'
// import Errors from '../views/Errors.vue'
// import Login from '../views/Login.vue'
// import Profile from '../views/Profile.vue'
// import Article from '../views/Article.vue'

// import Timeline from '../views/items/Timeline.vue'
// import Articles from '../views/items/Articles.vue'
// import Users from '../views/items/Users.vue'
// import Votes from '../views/items/Votes.vue'
// import Comments from '../views/items/Comments.vue'

// import AddArticle from '../views/add/Article.vue'
// import AddVote from '../views/add/Vote.vue'

Vue.use(VueRouter)

const base = '小鸟书法-'

export const router = new VueRouter({
  mode: 'history',
  routes: [
    { path: '/admin/', component: Index, meta: { title: `${base}首页` } },

    { path: '/admin/profile', component: resolve => require(['../views/Profile.vue'], resolve), meta: { title: `${base}个人资料` } },
    { path: '/admin/login', component: resolve => require(['../views/Login.vue'], resolve), meta: { title: `${base}登录` } },

    { path: '/admin/article', component: resolve => require(['../views/Article.vue'], resolve), meta: { title: `${base}预览` } },

    { path: '/admin/timeline', component: resolve => require(['../views/items/Timeline.vue'], resolve), meta: { title: `${base}内容` } },
    { path: '/admin/users', component: resolve => require(['../views/items/Users.vue'], resolve), meta: { title: `${base}管理员` } },
    { path: '/admin/visitor', component: resolve => require(['../views/items/visitor.vue'], resolve), meta: { title: `${base}用户` } },

    { path: '/admin/articles', component: resolve => require(['../views/items/Articles.vue'], resolve), meta: { title: `${base}产品` } },
    { path: '/admin/addArticle', component: resolve => require(['../views/add/Article.vue'], resolve), meta: { title: `${base}添加产品` } },
    { path: '/admin/votes', component: resolve => require(['../views/items/Votes.vue'], resolve), meta: { title: `${base}投票` } },
    { path: '/admin/addVote', component: resolve => require(['../views/add/Vote.vue'], resolve), meta: { title: `${base}添加投票` } },
    { path: '/admin/comments/:type', component: resolve => require(['../views/items/Comments.vue'], resolve), meta: { title: `${base}评论` } },
    { path: '/admin/versionmgt', component: resolve => require(['../views/items/version.vue'], resolve), meta: { title: `${base}版本&年级管理` } },

    { path: '*', component: resolve => require(['../views/Errors.vue'], resolve), meta: { title: `${base}Error` } }

  ]
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
})
